<?php
$s = new SaeStorage();
$access_token=$s->read( 'token' , 'token.txt');

//下载图片
$mediaid = "MCtPrFYueB8B3dnttO8H0LwXIJZyYQC0U68-eTTGSIakeAe50o0QMAh2VF4YXYu3";
$url = "http://file.api.weixin.qq.com/cgi-bin/media/get?access_token=$access_token&media_id=$mediaid";
$fileInfo = downloadWeixinFile($url);
//var_dump($fileInfo);
echo $fileInfo['header']['url'];
 
function downloadWeixinFile($url)
{
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HEADER, 0);    
    curl_setopt($ch, CURLOPT_NOBODY, 0);    //只取body头
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $package = curl_exec($ch);
    $httpinfo = curl_getinfo($ch);
    curl_close($ch);
    $imageAll = array_merge(array('header' => $httpinfo), array('body' => $package)); 
    return $imageAll;
}
?>